<template>
  <div class="search-item">
    <div class="swiper-wrapper">
        <img class="banner" :src="itemData.defaultPicture" alt="">
        <div class="bottom">
            <div class="msg-tip">
                <strong v-if="itemData.commentBrief.overall" class="score">{{ itemData.commentBrief.overall }}</strong>
                <span class="answer">{{ itemData.commentBrief.commentBrief }}</span>
            </div>
        </div>
        <div class="side-bar">
            <div class="tool-bar">
                <img class="avatar" :src="itemData.logoUrl" alt="">
                <div class="collection">
                    <img class="heart-img" src="@/assets/img/search/tj-mob-ui_unit-item_collected-new.png" alt="">
                    <span v-if="itemData.favoriteCount">{{ itemData.favoriteCount }}</span>
                </div>
                <div class="message">
                    <img class="msg-img" src="@/assets/img/search/tj-mob-ui_unit-item_comment-new.png" alt="">
                    <span>{{ itemData.commentBrief.totalCount }}</span>
                </div>
            </div>
        </div>
    </div>
    <div class="content">
        <div class="search-list-item-title">
            <div class="info">
                <van-tag color="#3f4954" text-color="#fff">{{ itemData.address}}</van-tag>
                <span class="name" v-if="itemData.unitSummeries[0].text">{{ itemData.unitSummeries[0].text }}</span>
                <span class="desp" v-if="itemData.unitSummeries[1].text ">{{ itemData.unitSummeries[1].text }}</span>
            </div>
            <div class="title">{{ itemData.unitName }}</div>
        </div>
        <div class="search-list-item-info">
            <div class="tags">
                <template v-for="(iten, inden ) in itemData.houseTags" :key="inden">
                    <van-tag :color="iten.background.color" :text-color="iten.color">{{iten.text }}</van-tag>
                </template>
            </div>
            <div class="price">
                <span class="real-price">{{ itemData.finalPrice }}</span>
                <span class="old-price">{{ itemData.productPrice }}</span>
                <van-tag
                v-if="itemData.priceTipBadge"
                round
                color="rgb(251, 74, 74)"
                text-color="#fff"
            >
                <i class="icon-unit-sound"></i>
                {{ itemData.priceTipBadge.text }}
                </van-tag>
            </div>
            <div v-if="itemData.promoContent" class="footer">
                <van-tag round color="transparent" text-color="#f66">{{
                    itemData.promoContent}}</van-tag>
            </div>
        </div>
    </div>
  </div>
</template>

<script setup>
const props=defineProps({
    itemData:{
        type:Object,
        default:()=>{}
    }
})
</script>

<style lang="less" scoped>
.search-list-item {
  margin: 10px 0px;
  
  
}
.swiper-wrapper {
  position: relative;
  .banner {
    width: 100%;
    border-radius: 6px;
    margin-bottom: 7px;
  }
  .bottom {
            .msg-tip {
        display: inline-flex;
        justify-content: center;
        align-items: center;
        max-width: 55%;

        height: 17px;
        padding-left: 6px;
        border-radius: 10px;
        background-color: hsla(0, 0%, 100%, 0.9);

        .score {
            font-size: 14px;
            transform: scale(0.8);
            transform-origin: 0 center;
            color: #333;
        }
        .answer {
            position: relative;
            font-size: 12px;
            transform: scale(0.8);
            transform-origin: 0 center;
            margin-left: -2px;
            padding-left: 5px;
            color: #666;
            &::before {
            content: " ";
            left: 0;
            top: 2px;
            position: absolute;
            height: 10px;
            width: 1px;
            background-color: #dadada;
            }
        }
        }
    position: absolute;
    bottom: 15px;
    left: 10px;
    right: 10px;
  }
  .side-bar {
            .tool-bar {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        }

        .avatar {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        margin-top: 5px;
        }
        .message,
        .collection {
        display: flex;
        flex-direction: column;
        align-items: center;
        margin-top: 10px;
        .msg-img,
        .heart-img {
            width: 30px;
            height: 30px;
        }
        span {
            color: white;
        }
        }
    position: absolute;
    top: 10px;
    right: 10px;
  }
}

.search-list-item-info {
        margin-top: 7px;
        .tags :deep(.van-tag) {
            margin-right: 6px;
        }

        .price {
            margin-top: 3px;
            margin-bottom: 7px;
            .real-price {
            position: relative;
            top: 1px;
            color: #ff9645;
            font-size: 20px;
            padding-right: 10px;
            padding-left: 1px;
            &::before {
                content: "¥";
                bottom: 0;
                font-size: 14px;
                padding-right: 3px;
            }
            }

            .old-price {
            font-weight: 500;
            font-size: 12px;
            color: #999;
            text-decoration: line-through;
            padding-right: 5px;
            }

            .icon-unit-sound {
            margin-right: 5px;
            display: inline-block;
            width: 10px;
            height: 10px;
            background-image: url(https://fe.tujiacdn.com/pwa/static/fevueui/images/unit-item-m/icon-unit-sound.png);
            background-size: 10px 10px;
            background-repeat: no-repeat;
            background-position: 50%;
            }
        }

        .price :deep(.van-tag) {
            position: relative;
            font-size: 12px;
            transform: scale(0.9);
        }
        }
    .search-list-item-title{
     .info {
    display: flex;
    align-items: center;

    .name,
    .desp {
        font-size: 12px;
        white-space: nowrap;
        color: #666;
    }
    .name {
        position: relative;
        margin-left: 10px;
        margin-right: 10px;

        &::after {
        position: absolute;
        content: "";
        top: 45%;
        right: -25%;
        width: 2px;
        height: 2px;
        border-radius: 2px;
        background-color: #666;
        }
    }
    }

    .title {
    line-height: 22px;
    font-size: 18px;
    margin-top: 8px;
    font-weight: 500;
    }
        }
 
</style>